//random test for adventurer card
//"reveal card from your deck unil you reveal two treasure cards. 
// Put those treasure cards in your hand and dicard the other revealed cards"
//
// card is played cardCount times, each time with a random hand

#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"
#include <time.h>
#include <stdlib.h>

#define DEBUG 0
#define NOISY_TEST 1

void randomizeHand(struct gameState * G, int player){
  int handCount = G->handCount[player];
  
  for (int i = 0; i < handCount; ++i)
  {
    int r = rand()%25;
    // printf("r:%d\n", r );
    G->hand[0][i] = r;
  }  
}

void printHand(struct gameState * G, int player){
  //go through each card in players hand and print it
  int handCount = G->handCount[player];
  int card;
  printf("Hand of player %d\n", player);
  for (int i = 0; i < handCount; ++i)
  {
    card = handCard(i, G);
    printf("%d\n",card);
  }  
}

int main () {
  srand(time(NULL));
  int r;
  int k[10] = {adventurer, council_room, feast, gardens, mine,
	       remodel, smithy, village, baron, great_hall};
  int bonus=0;
        
  struct gameState G;
  int testCount = 2000;
  int initCoin;
  int pass = 1;
  
  puts("\n\n********* TESTING ADVENTURER ************\n");
 
  for (int i = 0; i < testCount; ++i)
  {
    
    r = initializeGame(2, k, 123, &G);
    assert(r == 0);
    randomizeHand(&G,0);  //replace hand with random cards
    updateCoins(0, &G, 0); 
    initCoin = G.coins;

    cardEffect(adventurer,0,0,0,&G,1,&bonus);
    updateCoins(0, &G, 0);
    if (G.coins <= initCoin) //check for increase of coin
    {
      pass = 0;
    }
  }


  printf("Random test count: %d\n", testCount  );

  if (pass)
  {
    puts("Result: PASS");
  } else {
    puts("Result: FAIL");
  }
  

  
  return 0;
}




